IIdentifiableEqualityComparer<T>

Provides an equality comparer for objects that implement . Compares objects based on their Id property values for equality and hash code generation.

Syntax

public class IIdentifiableEqualityComparer<T> : IEqualityComparer<IIdentifiable<T>> where T : struct

Inheritance

Implements

Methods

Equals

public bool Equals(IIdentifiable<T> x, IIdentifiable<T> y)
Determines whether the specified objects are equal by comparing their Id properties.

Parameters

Returns

bool True if the objects are equal (including both being null), false otherwise.

GetHashCode

public int GetHashCode(IIdentifiable<T> obj)
Returns a hash code for the specified object based on its Id property.

Parameters

Returns

int A hash code for the specified object.

Exceptions

  • [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception): Thrown when obj is null.